/*
 * MainApplication.java
 *
 * Project: TECHWATCH - TESTING TECHNOLOGIES
 *
 * Copyright 2008 by ELCA Informatique SA
 * Av. de la Harpe 22-24, 1000 Lausanne 13
 * All rights reserved.
 *
 * This software is the confidential and proprietary information
 * of ELCA Informatique SA. ("Confidential Information"). You
 * shall not disclose such Confidential Information and shall
 * use it only in accordance with the terms of the license
 * agreement you entered into with ELCA.
 */

package ch.elca.training;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import ch.elca.training.dao.EmployeeDao;
import ch.elca.training.dom.Employee;


/**
 * The entry point for launching the application.
 *
 * <script type="text/javascript">printFileStatus
 *   ("$URL: https://cvs.elca.ch/subversion/cxnet-portal/trunk/etc/eclipse/preferences_2008_03_03.epf $",
 *    "$Revision: 334 $",
 *    "$Date: 2008-03-03 16:07:32 +0700 (Mon, 03 Mar 2008) $",
 *    "$Author: qkp@ELCA.CH $"
 *    "$Id:$"
 * );</script>
 *
 * @author qkp
 */
public class MainApplication {
    private static final Log s_logger = LogFactory.getLog(MainApplication.class);

    private static final String[] INCLUSIVE_CONFIG_LOCATIONS = {
        "classpath*:mandatory/*.xml",
        "classpath*:scenarios/dataaccess/hibernate/*.xml",
        "classpath*:scenarios/tx/local/*.xml"};

    private static ApplicationContext s_applicationContext = null;
    
    /**
     * Initiate the application context with Spring.
     */
    private static void startup() {
         s_applicationContext = new ClassPathXmlApplicationContext(INCLUSIVE_CONFIG_LOCATIONS, true);
    }
 
    /**
     * @param args
     */
    public static void main(String[] args) {
        s_logger.info("Starting up ...");
        startup();
        
        EmployeeDao employeeDao = s_applicationContext.getBean(EmployeeDao.class);
        employeeDao.deleteAll();
        Employee employee = new Employee();
        employee.setVisa("PHD");
        employeeDao.saveOrUpdate(employee );
        
        s_logger.info("Finished.");
    }
}